package com.yj.springbootaop.cglibproxy;

import org.springframework.cglib.proxy.Callback;
import org.springframework.cglib.proxy.Enhancer;

public class Test {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(AliSmsService.class);
        enhancer.setClassLoader(AliSmsService.class.getClassLoader());
        enhancer.setCallback(new MyMethodInterceptor());
        AliSmsService aliSmsService = (AliSmsService) enhancer.create();
        aliSmsService.send("hello");

        AliSmsService aliSmsServiceProxy = (AliSmsService) CglibProxyFactory.getProxyObject(AliSmsService.class);
        aliSmsServiceProxy.send("hello world!");
    }
}
